package com.chixing.dao.impl;

import com.chixing.dao.RowMapper;
import com.chixing.pojo.Employee;

import java.sql.ResultSet;
import java.sql.SQLException;

public class EmployeeRowMapper  implements RowMapper<Employee> {
    @Override
    public Employee mapper(ResultSet rs) {
        Employee employee = null;
        try {
            while (rs.next()) {
                int empno =  rs.getInt(1); //rs.getObject(1)
                String ename = rs.getString(2);//rs.getObject(2)
                String job = rs.getString(3);//rs.getObject(3)
                java.util.Date hiredate =  rs.getDate(4);
                int mgr = rs.getInt(5);
                float salary = rs.getFloat(6);
                float comm = rs.getFloat(7);
                int deptno = rs.getInt(8);

                employee = new 	Employee(empno,ename,job,mgr,hiredate,salary,comm,deptno);
            }
        } catch (SQLException e) {
                e.printStackTrace();
        }
        return employee;
    }
}
